import xlrd
import pyecharts.options as opts
data=xlrd.open_workbook(r'C:\Users\chumenliuxiang\Desktop\实验室作业\第一问\第一问.xls','r')
sheet_num=data.nsheets
# print(sheet_num)
biao1=data.sheet_by_name('Sheet1')
scores=biao1.col_values(1)
scores=scores[1:]

a=b=c=d=e=0
for i in scores:
    if i<60:
        e=e+1
    elif i<70:
        d+=1
    elif i<80:
        c+=1
    elif i<90:
        b+=1
    elif i<=100:
        a+=1
student=[]
student.append(e)
student.append(d)
student.append(c)
student.append(b)
student.append(a)
# print(student)
shuju=['E(0~60)','D(61~70)','C(71~80)','B(81~90)','A(91~100)']
#——————————————————————————数据处理完毕
from pyecharts import options as opts
from pyecharts.charts import Bar
(
    Bar()
    .add_xaxis(shuju)
    .add_yaxis("成绩",student)
    .set_global_opts(
        title_opts=opts.TitleOpts(title="学生成绩的柱状图",pos_left='center',pos_bottom='1%'),
        yaxis_opts=opts.AxisOpts(name="学生人数"),
        xaxis_opts=opts.AxisOpts(name="分数等级"),
    )
    .render("第六问.html")
)